Skip to content

Commit

Permalink
Merge TTF changes to fix off-by-one error.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Oct 6, 2023
1 parent 19c4587 commit 59959bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
9 changes: 4 additions & 5 deletions ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
//
// https://github.com/michaelrsweet/ttf
//
// Copyright © 2018-2021 by Michael R Sweet.
// Copyright © 2018-2023 by Michael R Sweet.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
//

//
// Include necessary headers...
//

#ifdef _WIN32
# define _CRT_SECURE_NO_WARNINGS
#endif // _WIN32
Expand Down Expand Up @@ -691,6 +687,9 @@ ttfGetExtents(
ch = *s++;
}

// Issue #1: Offset past ".notdef"...
ch ++;

// Find its width...
if ((widths = font->widths[ch / 256]) != NULL)
{
Expand Down
13 changes: 3 additions & 10 deletions ttf.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,19 @@
//
// https://github.com/michaelrsweet/ttf
//
// Copyright © 2018-2021 by Michael R Sweet.
// Copyright © 2018-2023 by Michael R Sweet.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
//

#ifndef TTF_H
# define TTF_H

//
// Include necessary headers...
//

# include <stdbool.h>
# include <sys/types.h>

# ifdef __cplusplus
extern "C" {
# endif //
# endif // __cplusplus


//
Expand Down Expand Up @@ -89,8 +83,8 @@ extern ttf_t *ttfCreate(const char *filename, size_t idx, ttf_err_cb_t err_cb,
extern void ttfDelete(ttf_t *font);
extern int ttfGetAscent(ttf_t *font);
extern ttf_rect_t *ttfGetBounds(ttf_t *font, ttf_rect_t *bounds);
extern int ttfGetCapHeight(ttf_t *font);
extern const int *ttfGetCMap(ttf_t *font, size_t *num_cmap);
extern int ttfGetCapHeight(ttf_t *font);
extern const char *ttfGetCopyright(ttf_t *font);
extern int ttfGetDescent(ttf_t *font);
extern ttf_rect_t *ttfGetExtents(ttf_t *font, float size, const char *s, ttf_rect_t *extents);
Expand All @@ -112,5 +106,4 @@ extern bool ttfIsFixedPitch(ttf_t *font);
# ifdef __cplusplus
}
# endif // __cplusplus

#endif // !TTF_H

0 comments on commit 59959bf

Please sign in to comment.