mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-25 12:58:21 +01:00
Merge TTF v1.0.0 source files.
This commit is contained in:
parent
1cec42f399
commit
d7cce4dfbc
36
ttf.c
36
ttf.c
@ -62,7 +62,7 @@
|
||||
# define O_CREAT _O_CREAT
|
||||
# define O_TRUNC _O_TRUNC
|
||||
|
||||
typedef __int64 ssize_t; // POSIX type not present on Windows...
|
||||
typedef __int64 ssize_t; // POSIX type not present on Windows... @private@
|
||||
|
||||
#else
|
||||
# include <unistd.h>
|
||||
@ -299,7 +299,28 @@ static unsigned seek_table(ttf_t *font, unsigned tag, unsigned offset, bool requ
|
||||
|
||||
|
||||
//
|
||||
// 'ttfCreate()' - Create a new font object for the named font family.
|
||||
// 'ttfCreate()' - Create a new font object for the named font file.
|
||||
//
|
||||
// This function creates a new font object for the named TrueType or OpenType
|
||||
// font file or collection. The "filename" argument specifies the name of the
|
||||
// file to read.
|
||||
//
|
||||
// The "idx" argument specifies the font to load from a collection - the first
|
||||
// font is number `0`. Once created, you can call the @link ttfGetNumFonts@
|
||||
// function to determine whether the loaded font file is a collection with more
|
||||
// than one font.
|
||||
//
|
||||
// The "err_cb" and "err_data" arguments specify a callback function and data
|
||||
// pointer for receiving error messages. If `NULL`, errors are sent to the
|
||||
// `stderr` file. The callback function receives the data pointer and a text
|
||||
// message string, for example:
|
||||
//
|
||||
// ```
|
||||
// void my_err_cb(void *err_data, const char *message)
|
||||
// {
|
||||
// fprintf(stderr, "ERROR: %s\n", message);
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
|
||||
ttf_t * // O - New font object
|
||||
@ -552,6 +573,10 @@ ttfGetAscent(ttf_t *font) // I - Font
|
||||
//
|
||||
// 'ttfGetBounds()' - Get the bounds of all characters in a font.
|
||||
//
|
||||
// This function gets the bounds of all characters in a font. The "bounds"
|
||||
// argument is a pointer to a `ttf_rect_t` structure that will be filled with
|
||||
// the limits for characters in the font scaled to a 1000x1000 unit square.
|
||||
//
|
||||
|
||||
ttf_rect_t * // O - Bounds or `NULL` on error
|
||||
ttfGetBounds(ttf_t *font, // I - Font
|
||||
@ -633,8 +658,11 @@ ttfGetDescent(ttf_t *font) // I - Font
|
||||
//
|
||||
// 'ttfGetExtents()' - Get the extents of a UTF-8 string.
|
||||
//
|
||||
// This function computes the extents of a UTF-8 string when rendered using the
|
||||
// specified font and size.
|
||||
// This function computes the extents of the UTF-8 string "s" when rendered
|
||||
// using the specified font "font" and size "size". The "extents" argument is
|
||||
// a pointer to a `ttf_rect_t` structure that is filled with the extents of a
|
||||
// simple rendering of the string with no kerning or rewriting applied. The
|
||||
// values are scaled using the specified font size.
|
||||
//
|
||||
|
||||
ttf_rect_t * // O - Pointer to extents or `NULL` on error
|
||||
|
16
ttf.h
16
ttf.h
@ -3,7 +3,7 @@
|
||||
//
|
||||
// https://github.com/michaelrsweet/ttf
|
||||
//
|
||||
// Copyright © 2018-2023 by Michael R Sweet.
|
||||
// Copyright © 2018-2024 by Michael R Sweet.
|
||||
//
|
||||
// Licensed under Apache License v2.0. See the file "LICENSE" for more
|
||||
// information.
|
||||
@ -22,12 +22,12 @@ extern "C" {
|
||||
// Types...
|
||||
//
|
||||
|
||||
typedef struct _ttf_s ttf_t; //// Font object
|
||||
typedef struct _ttf_s ttf_t; // Font object
|
||||
|
||||
typedef void (*ttf_err_cb_t)(void *data, const char *message);
|
||||
//// Font error callback
|
||||
// Font error callback
|
||||
|
||||
typedef enum ttf_stretch_e //// Font stretch
|
||||
typedef enum ttf_stretch_e // Font stretch
|
||||
{
|
||||
TTF_STRETCH_NORMAL, // normal
|
||||
TTF_STRETCH_ULTRA_CONDENSED, // ultra-condensed
|
||||
@ -40,20 +40,20 @@ typedef enum ttf_stretch_e //// Font stretch
|
||||
TTF_STRETCH_ULTRA_EXPANDED // ultra-expanded
|
||||
} ttf_stretch_t;
|
||||
|
||||
typedef enum ttf_style_e //// Font style
|
||||
typedef enum ttf_style_e // Font style
|
||||
{
|
||||
TTF_STYLE_NORMAL, // Normal font
|
||||
TTF_STYLE_ITALIC, // Italic font
|
||||
TTF_STYLE_OBLIQUE // Oblique (angled) font
|
||||
} ttf_style_t;
|
||||
|
||||
typedef enum ttf_variant_e //// Font variant
|
||||
typedef enum ttf_variant_e // Font variant
|
||||
{
|
||||
TTF_VARIANT_NORMAL, // Normal font
|
||||
TTF_VARIANT_SMALL_CAPS // Font whose lowercase letters are small capitals
|
||||
} ttf_variant_t;
|
||||
|
||||
typedef enum ttf_weight_e //// Font weight
|
||||
typedef enum ttf_weight_e // Font weight
|
||||
{
|
||||
TTF_WEIGHT_100 = 100, // Weight 100 (Thin)
|
||||
TTF_WEIGHT_200 = 200, // Weight 200 (Extra/Ultra-Light)
|
||||
@ -66,7 +66,7 @@ typedef enum ttf_weight_e //// Font weight
|
||||
TTF_WEIGHT_900 = 900 // Weight 900 (Black/Heavy)
|
||||
} ttf_weight_t;
|
||||
|
||||
typedef struct ttf_rect_s //// Bounding rectangle
|
||||
typedef struct ttf_rect_s // Bounding rectangle
|
||||
{
|
||||
float left; // Left offset
|
||||
float top; // Top offset
|
||||
|
Loading…
Reference in New Issue
Block a user