Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed





















































































Rev Author Line No. Line
4349 Serge 1
2
"http://www.w3.org/TR/html4/loose.dtd">
3
4
5
6
FreeType-2.5.0 API Reference
7
32
33
34
 
35
[Index]
36
37
[TOC]
38

FreeType-2.5.0 API Reference

39
 
40

41
Cache Sub-System
42
43

Synopsis

44
45
FTC_ManagerFTC_CMapCache_New
46
FTC_FaceIDFTC_CMapCache_Lookup
47
FTC_Face_RequesterFTC_ImageTypeRec
48
FTC_NodeFTC_ImageType
49
FTC_Manager_NewFTC_ImageCache
50
FTC_Manager_ResetFTC_ImageCache_New
51
FTC_Manager_DoneFTC_ImageCache_Lookup
52
FTC_Manager_LookupFaceFTC_ImageCache_LookupScaler
53
FTC_ScalerRecFTC_SBit
54
FTC_ScalerFTC_SBitRec
55
FTC_Manager_LookupSizeFTC_SBitCache
56
FTC_Node_UnrefFTC_SBitCache_New
57
FTC_Manager_RemoveFaceIDFTC_SBitCache_Lookup
58
FTC_CMapCacheFTC_SBitCache_LookupScaler
59


60
 
61
62

This section describes the FreeType 2 cache sub-system, which is used to limit the number of concurrently opened FT_Face and FT_Size objects, as well as caching information like character maps and glyph images while limiting their maximum memory usage.

63

Note that all types and functions begin with the ‘FTC_’ prefix.

64

The cache is highly portable and thus doesn't know anything about the fonts installed on your system, or how to access them. This implies the following scheme:

65

First, available or installed font faces are uniquely identified by FTC_FaceID values, provided to the cache by the client. Note that the cache only stores and compares these values, and doesn't try to interpret them in any way.

66

Second, the cache calls, only when needed, a client-provided function to convert an FTC_FaceID into a new FT_Face object. The latter is then completely managed by the cache, including its termination through FT_Done_Face. To monitor termination of face objects, the finalizer callback in the ‘generic’ field of the FT_Face object can be used, which might also be used to store the FTC_FaceID of the face.

67

Clients are free to map face IDs to anything else. The most simple usage is to associate them to a (pathname,face_index) pair that is used to call FT_New_Face. However, more complex schemes are also possible.

68

Note that for the cache to work correctly, the face ID values must be persistent, which means that the contents they point to should not change at runtime, or that their value should not become invalid.

69

If this is unavoidable (e.g., when a font is uninstalled at runtime), you should call FTC_Manager_RemoveFaceID as soon as possible, to let the cache get rid of any references to the old FTC_FaceID it may keep internally. Failure to do so will lead to incorrect behaviour or even crashes.

70

To use the cache, start with calling FTC_Manager_New to create a new FTC_Manager object, which models a single cache instance. You can then look up FT_Face and FT_Size objects with FTC_Manager_LookupFace and FTC_Manager_LookupSize, respectively.

71

If you want to use the charmap caching, call FTC_CMapCache_New, then later use FTC_CMapCache_Lookup to perform the equivalent of FT_Get_Char_Index, only much faster.

72

If you want to use the FT_Glyph caching, call FTC_ImageCache, then later use FTC_ImageCache_Lookup to retrieve the corresponding FT_Glyph objects from the cache.

73

If you need lots of small bitmaps, it is much more memory efficient to call FTC_SBitCache_New followed by FTC_SBitCache_Lookup. This returns FTC_SBitRec structures, which are used to store small bitmaps directly. (A small bitmap is one whose metrics and dimensions all fit into 8-bit integers).

74

We hope to also provide a kerning cache in the near future.

75

76
77

FTC_Manager

78
79
Defined in FT_CACHE_H (freetype/ftcache.h).
80

81
82
 
83
  typedef struct FTC_ManagerRec_*  FTC_Manager;
84
 
85

86
87

This object corresponds to one instance of the cache-subsystem. It is used to cache one or more FT_Face objects, along with corresponding FT_Size objects.

88

The manager intentionally limits the total number of opened FT_Face and FT_Size objects to control memory usage. See the ‘max_faces’ and ‘max_sizes’ parameters of FTC_Manager_New.

89

The manager is also used to cache ‘nodes’ of various types while limiting their total memory usage.

90

All limitations are enforced by keeping lists of managed objects in most-recently-used order, and flushing old nodes to make room for new ones.

91

92
93

94
[Index]
95
96
[TOC]
97
 
98
99

FTC_FaceID

100
101
Defined in FT_CACHE_H (freetype/ftcache.h).
102

103
104
 
105
  typedef FT_Pointer  FTC_FaceID;
106
 
107

108
109

An opaque pointer type that is used to identity face objects. The contents of such objects is application-dependent.

110

These pointers are typically used to point to a user-defined structure containing a font file path, and face index.

111

112
note
113

Never use NULL as a valid FTC_FaceID.

114

Face IDs are passed by the client to the cache manager, which calls, when needed, the FTC_Face_Requester to translate them into new FT_Face objects.

115

If the content of a given face ID changes at runtime, or if the value becomes invalid (e.g., when uninstalling a font), you should immediately call FTC_Manager_RemoveFaceID before any other cache function.

116

Failure to do so will result in incorrect behaviour or even memory leaks and crashes.

117
118
119

120
[Index]
121
122
[TOC]
123
 
124
125

FTC_Face_Requester

126
127
Defined in FT_CACHE_H (freetype/ftcache.h).
128

129
130
 
131
  typedef FT_Error
132
  (*FTC_Face_Requester)( FTC_FaceID  face_id,
133
                         FT_Library  library,
134
                         FT_Pointer  request_data,
135
                         FT_Face*    aface );
136
 
137

138
139

A callback function provided by client applications. It is used by the cache manager to translate a given FTC_FaceID into a new valid FT_Face object, on demand.

140

141
input
142

143
144
face_id
145

The face ID to resolve.

146
147
library
148

A handle to a FreeType library object.

149
150
req_data
151

Application-provided request data (see note below).

152
153
154
155
output
156

157
158
aface
159

A new FT_Face handle.

160
161
162
163
return
164

FreeType error code. 0 means success.

165
166
note
167

The third parameter ‘req_data’ is the same as the one passed by the client when FTC_Manager_New is called.

168

The face requester should not perform funny things on the returned face object, like creating a new FT_Size for it, or setting a transformation through FT_Set_Transform!

169
170
171

172
[Index]
173
174
[TOC]
175
 
176
177

FTC_Node

178
179
Defined in FT_CACHE_H (freetype/ftcache.h).
180

181
182
 
183
  typedef struct FTC_NodeRec_*  FTC_Node;
184
 
185

186
187

An opaque handle to a cache node object. Each cache node is reference-counted. A node with a count of 0 might be flushed out of a full cache whenever a lookup request is performed.

188

If you look up nodes, you have the ability to ‘acquire’ them, i.e., to increment their reference count. This will prevent the node from being flushed out of the cache until you explicitly ‘release’ it (see FTC_Node_Unref).

189

See also FTC_SBitCache_Lookup and FTC_ImageCache_Lookup.

190

191
192

193
[Index]
194
195
[TOC]
196
 
197
198

FTC_Manager_New

199
200
Defined in FT_CACHE_H (freetype/ftcache.h).
201

202
203
 
204
  FT_EXPORT( FT_Error )
205
  FTC_Manager_New( FT_Library          library,
206
                   FT_UInt             max_faces,
207
                   FT_UInt             max_sizes,
208
                   FT_ULong            max_bytes,
209
                   FTC_Face_Requester  requester,
210
                   FT_Pointer          req_data,
211
                   FTC_Manager        *amanager );
212
 
213

214
215

Create a new cache manager.

216

217
input
218

219
220
library
221

The parent FreeType library handle to use.

222
223
max_faces
224

Maximum number of opened FT_Face objects managed by this cache instance. Use 0 for defaults.

225
226
max_sizes
227

Maximum number of opened FT_Size objects managed by this cache instance. Use 0 for defaults.

228
229
max_bytes
230

Maximum number of bytes to use for cached data nodes. Use 0 for defaults. Note that this value does not account for managed FT_Face and FT_Size objects.

231
232
requester
233

An application-provided callback used to translate face IDs into real FT_Face objects.

234
235
req_data
236

A generic pointer that is passed to the requester each time it is called (see FTC_Face_Requester).

237
238
239
240
output
241

242
243
amanager
244

A handle to a new manager object. 0 in case of failure.

245
246
247
248
return
249

FreeType error code. 0 means success.

250
251
252

253
[Index]
254
255
[TOC]
256
 
257
258

FTC_Manager_Reset

259
260
Defined in FT_CACHE_H (freetype/ftcache.h).
261

262
263
 
264
  FT_EXPORT( void )
265
  FTC_Manager_Reset( FTC_Manager  manager );
266
 
267

268
269

Empty a given cache manager. This simply gets rid of all the currently cached FT_Face and FT_Size objects within the manager.

270

271
inout
272

273
274
manager
275

A handle to the manager.

276
277
278
279
280

281
[Index]
282
283
[TOC]
284
 
285
286

FTC_Manager_Done

287
288
Defined in FT_CACHE_H (freetype/ftcache.h).
289

290
291
 
292
  FT_EXPORT( void )
293
  FTC_Manager_Done( FTC_Manager  manager );
294
 
295

296
297

Destroy a given manager after emptying it.

298

299
input
300

301
302
manager
303

A handle to the target cache manager object.

304
305
306
307
308

309
[Index]
310
311
[TOC]
312
 
313
314

FTC_Manager_LookupFace

315
316
Defined in FT_CACHE_H (freetype/ftcache.h).
317

318
319
 
320
  FT_EXPORT( FT_Error )
321
  FTC_Manager_LookupFace( FTC_Manager  manager,
322
                          FTC_FaceID   face_id,
323
                          FT_Face     *aface );
324
 
325

326
327

Retrieve the FT_Face object that corresponds to a given face ID through a cache manager.

328

329
input
330

331
332
manager
333

A handle to the cache manager.

334
335
face_id
336

The ID of the face object.

337
338
339
340
output
341

342
343
aface
344

A handle to the face object.

345
346
347
348
return
349

FreeType error code. 0 means success.

350
351
note
352

The returned FT_Face object is always owned by the manager. You should never try to discard it yourself.

353

The FT_Face object doesn't necessarily have a current size object (i.e., face->size can be 0). If you need a specific ‘font size’, use FTC_Manager_LookupSize instead.

354

Never change the face's transformation matrix (i.e., never call the FT_Set_Transform function) on a returned face! If you need to transform glyphs, do it yourself after glyph loading.

355

When you perform a lookup, out-of-memory errors are detected within the lookup and force incremental flushes of the cache until enough memory is released for the lookup to succeed.

356

If a lookup fails with ‘FT_Err_Out_Of_Memory’ the cache has already been completely flushed, and still no memory was available for the operation.

357
358
359

360
[Index]
361
362
[TOC]
363
 
364
365

FTC_ScalerRec

366
367
Defined in FT_CACHE_H (freetype/ftcache.h).
368

369
370
 
371
  typedef struct  FTC_ScalerRec_
372
  {
373
    FTC_FaceID  face_id;
374
    FT_UInt     width;
375
    FT_UInt     height;
376
    FT_Int      pixel;
377
    FT_UInt     x_res;
378
    FT_UInt     y_res;
379
 
380
  } FTC_ScalerRec;
381
 
382

383
384

A structure used to describe a given character size in either pixels or points to the cache manager. See FTC_Manager_LookupSize.

385

386
fields
387

388
389
face_id
390

The source face ID.

391
392
width
393

The character width.

394
395
height
396

The character height.

397
398
pixel
399

A Boolean. If 1, the ‘width’ and ‘height’ fields are interpreted as integer pixel character sizes. Otherwise, they are expressed as 1/64th of points.

400
401
x_res
402

Only used when ‘pixel’ is value 0 to indicate the horizontal resolution in dpi.

403
404
y_res
405

Only used when ‘pixel’ is value 0 to indicate the vertical resolution in dpi.

406
407
408
409
note
410

This type is mainly used to retrieve FT_Size objects through the cache manager.

411
412
413

414
[Index]
415
416
[TOC]
417
 
418
419

FTC_Scaler

420
421
Defined in FT_CACHE_H (freetype/ftcache.h).
422

423
424
 
425
  typedef struct FTC_ScalerRec_*  FTC_Scaler;
426
 
427

428
429

A handle to an FTC_ScalerRec structure.

430

431
432

433
[Index]
434
435
[TOC]
436
 
437
438

FTC_Manager_LookupSize

439
440
Defined in FT_CACHE_H (freetype/ftcache.h).
441

442
443
 
444
  FT_EXPORT( FT_Error )
445
  FTC_Manager_LookupSize( FTC_Manager  manager,
446
                          FTC_Scaler   scaler,
447
                          FT_Size     *asize );
448
 
449

450
451

Retrieve the FT_Size object that corresponds to a given FTC_ScalerRec pointer through a cache manager.

452

453
input
454

455
456
manager
457

A handle to the cache manager.

458
459
scaler
460

A scaler handle.

461
462
463
464
output
465

466
467
asize
468

A handle to the size object.

469
470
471
472
return
473

FreeType error code. 0 means success.

474
475
note
476

The returned FT_Size object is always owned by the manager. You should never try to discard it by yourself.

477

You can access the parent FT_Face object simply as ‘size->face’ if you need it. Note that this object is also owned by the manager.

478
479
note
480

When you perform a lookup, out-of-memory errors are detected within the lookup and force incremental flushes of the cache until enough memory is released for the lookup to succeed.

481

If a lookup fails with ‘FT_Err_Out_Of_Memory’ the cache has already been completely flushed, and still no memory is available for the operation.

482
483
484

485
[Index]
486
487
[TOC]
488
 
489
490

FTC_Node_Unref

491
492
Defined in FT_CACHE_H (freetype/ftcache.h).
493

494
495
 
496
  FT_EXPORT( void )
497
  FTC_Node_Unref( FTC_Node     node,
498
                  FTC_Manager  manager );
499
 
500

501
502

Decrement a cache node's internal reference count. When the count reaches 0, it is not destroyed but becomes eligible for subsequent cache flushes.

503

504
input
505

506
507
node
508

The cache node handle.

509
510
manager
511

The cache manager handle.

512
513
514
515
516

517
[Index]
518
519
[TOC]
520
 
521
522

FTC_Manager_RemoveFaceID

523
524
Defined in FT_CACHE_H (freetype/ftcache.h).
525

526
527
 
528
  FT_EXPORT( void )
529
  FTC_Manager_RemoveFaceID( FTC_Manager  manager,
530
                            FTC_FaceID   face_id );
531
 
532

533
534

A special function used to indicate to the cache manager that a given FTC_FaceID is no longer valid, either because its content changed, or because it was deallocated or uninstalled.

535

536
input
537

538
539
manager
540

The cache manager handle.

541
542
face_id
543

The FTC_FaceID to be removed.

544
545
546
547
note
548

This function flushes all nodes from the cache corresponding to this ‘face_id’, with the exception of nodes with a non-null reference count.

549

Such nodes are however modified internally so as to never appear in later lookups with the same ‘face_id’ value, and to be immediately destroyed when released by all their users.

550
551
552

553
[Index]
554
555
[TOC]
556
 
557
558

FTC_CMapCache

559
560
Defined in FT_CACHE_H (freetype/ftcache.h).
561

562
563
 
564
  typedef struct FTC_CMapCacheRec_*  FTC_CMapCache;
565
 
566

567
568

An opaque handle used to model a charmap cache. This cache is to hold character codes -> glyph indices mappings.

569

570
571

572
[Index]
573
574
[TOC]
575
 
576
577

FTC_CMapCache_New

578
579
Defined in FT_CACHE_H (freetype/ftcache.h).
580

581
582
 
583
  FT_EXPORT( FT_Error )
584
  FTC_CMapCache_New( FTC_Manager     manager,
585
                     FTC_CMapCache  *acache );
586
 
587

588
589

Create a new charmap cache.

590

591
input
592

593
594
manager
595

A handle to the cache manager.

596
597
598
599
output
600

601
602
acache
603

A new cache handle. NULL in case of error.

604
605
606
607
return
608

FreeType error code. 0 means success.

609
610
note
611

Like all other caches, this one will be destroyed with the cache manager.

612
613
614

615
[Index]
616
617
[TOC]
618
 
619
620

FTC_CMapCache_Lookup

621
622
Defined in FT_CACHE_H (freetype/ftcache.h).
623

624
625
 
626
  FT_EXPORT( FT_UInt )
627
  FTC_CMapCache_Lookup( FTC_CMapCache  cache,
628
                        FTC_FaceID     face_id,
629
                        FT_Int         cmap_index,
630
                        FT_UInt32      char_code );
631
 
632

633
634

Translate a character code into a glyph index, using the charmap cache.

635

636
input
637

638
639
cache
640

A charmap cache handle.

641
642
face_id
643

The source face ID.

644
645
cmap_index
646

The index of the charmap in the source face. Any negative value means to use the cache FT_Face's default charmap.

647
648
char_code
649

The character code (in the corresponding charmap).

650
651
652
653
return
654

Glyph index. 0 means ‘no glyph’.

655
656
657

658
[Index]
659
660
[TOC]
661
 
662
663

FTC_ImageTypeRec

664
665
Defined in FT_CACHE_H (freetype/ftcache.h).
666

667
668
 
669
  typedef struct  FTC_ImageTypeRec_
670
  {
671
    FTC_FaceID  face_id;
672
    FT_Int      width;
673
    FT_Int      height;
674
    FT_Int32    flags;
675
 
676
  } FTC_ImageTypeRec;
677
 
678

679
680

A structure used to model the type of images in a glyph cache.

681

682
fields
683

684
685
face_id
686

The face ID.

687
688
width
689

The width in pixels.

690
691
height
692

The height in pixels.

693
694
flags
695

The load flags, as in FT_Load_Glyph.

696
697
698
699
700

701
[Index]
702
703
[TOC]
704
 
705
706

FTC_ImageType

707
708
Defined in FT_CACHE_H (freetype/ftcache.h).
709

710
711
 
712
  typedef struct FTC_ImageTypeRec_*  FTC_ImageType;
713
 
714

715
716

A handle to an FTC_ImageTypeRec structure.

717

718
719

720
[Index]
721
722
[TOC]
723
 
724
725

FTC_ImageCache

726
727
Defined in FT_CACHE_H (freetype/ftcache.h).
728

729
730
 
731
  typedef struct FTC_ImageCacheRec_*  FTC_ImageCache;
732
 
733

734
735

A handle to a glyph image cache object. They are designed to hold many distinct glyph images while not exceeding a certain memory threshold.

736

737
738

739
[Index]
740
741
[TOC]
742
 
743
744

FTC_ImageCache_New

745
746
Defined in FT_CACHE_H (freetype/ftcache.h).
747

748
749
 
750
  FT_EXPORT( FT_Error )
751
  FTC_ImageCache_New( FTC_Manager      manager,
752
                      FTC_ImageCache  *acache );
753
 
754

755
756

Create a new glyph image cache.

757

758
input
759

760
761
manager
762

The parent manager for the image cache.

763
764
765
766
output
767

768
769
acache
770

A handle to the new glyph image cache object.

771
772
773
774
return
775

FreeType error code. 0 means success.

776
777
778

779
[Index]
780
781
[TOC]
782
 
783
784

FTC_ImageCache_Lookup

785
786
Defined in FT_CACHE_H (freetype/ftcache.h).
787

788
789
 
790
  FT_EXPORT( FT_Error )
791
  FTC_ImageCache_Lookup( FTC_ImageCache  cache,
792
                         FTC_ImageType   type,
793
                         FT_UInt         gindex,
794
                         FT_Glyph       *aglyph,
795
                         FTC_Node       *anode );
796
 
797

798
799

Retrieve a given glyph image from a glyph image cache.

800

801
input
802

803
804
cache
805

A handle to the source glyph image cache.

806
807
type
808

A pointer to a glyph image type descriptor.

809
810
gindex
811

The glyph index to retrieve.

812
813
814
815
output
816

817
818
aglyph
819

The corresponding FT_Glyph object. 0 in case of failure.

820
821
anode
822

Used to return the address of of the corresponding cache node after incrementing its reference count (see note below).

823
824
825
826
return
827

FreeType error code. 0 means success.

828
829
note
830

The returned glyph is owned and managed by the glyph image cache. Never try to transform or discard it manually! You can however create a copy with FT_Glyph_Copy and modify the new one.

831

If ‘anode’ is not NULL, it receives the address of the cache node containing the glyph image, after increasing its reference count. This ensures that the node (as well as the FT_Glyph) will always be kept in the cache until you call FTC_Node_Unref to ‘release’ it.

832

If ‘anode’ is NULL, the cache node is left unchanged, which means that the FT_Glyph could be flushed out of the cache on the next call to one of the caching sub-system APIs. Don't assume that it is persistent!

833
834
835

836
[Index]
837
838
[TOC]
839
 
840
841

FTC_ImageCache_LookupScaler

842
843
Defined in FT_CACHE_H (freetype/ftcache.h).
844

845
846
 
847
  FT_EXPORT( FT_Error )
848
  FTC_ImageCache_LookupScaler( FTC_ImageCache  cache,
849
                               FTC_Scaler      scaler,
850
                               FT_ULong        load_flags,
851
                               FT_UInt         gindex,
852
                               FT_Glyph       *aglyph,
853
                               FTC_Node       *anode );
854
 
855

856
857

A variant of FTC_ImageCache_Lookup that uses an FTC_ScalerRec to specify the face ID and its size.

858

859
input
860

861
862
cache
863

A handle to the source glyph image cache.

864
865
scaler
866

A pointer to a scaler descriptor.

867
868
load_flags
869

The corresponding load flags.

870
871
gindex
872

The glyph index to retrieve.

873
874
875
876
output
877

878
879
aglyph
880

The corresponding FT_Glyph object. 0 in case of failure.

881
882
anode
883

Used to return the address of of the corresponding cache node after incrementing its reference count (see note below).

884
885
886
887
return
888

FreeType error code. 0 means success.

889
890
note
891

The returned glyph is owned and managed by the glyph image cache. Never try to transform or discard it manually! You can however create a copy with FT_Glyph_Copy and modify the new one.

892

If ‘anode’ is not NULL, it receives the address of the cache node containing the glyph image, after increasing its reference count. This ensures that the node (as well as the FT_Glyph) will always be kept in the cache until you call FTC_Node_Unref to ‘release’ it.

893

If ‘anode’ is NULL, the cache node is left unchanged, which means that the FT_Glyph could be flushed out of the cache on the next call to one of the caching sub-system APIs. Don't assume that it is persistent!

894

Calls to FT_Set_Char_Size and friends have no effect on cached glyphs; you should always use the FreeType cache API instead.

895
896
897

898
[Index]
899
900
[TOC]
901
 
902
903

FTC_SBit

904
905
Defined in FT_CACHE_H (freetype/ftcache.h).
906

907
908
 
909
  typedef struct FTC_SBitRec_*  FTC_SBit;
910
 
911

912
913

A handle to a small bitmap descriptor. See the FTC_SBitRec structure for details.

914

915
916

917
[Index]
918
919
[TOC]
920
 
921
922

FTC_SBitRec

923
924
Defined in FT_CACHE_H (freetype/ftcache.h).
925

926
927
 
928
  typedef struct  FTC_SBitRec_
929
  {
930
    FT_Byte   width;
931
    FT_Byte   height;
932
    FT_Char   left;
933
    FT_Char   top;
934
 
935
    FT_Byte   format;
936
    FT_Byte   max_grays;
937
    FT_Short  pitch;
938
    FT_Char   xadvance;
939
    FT_Char   yadvance;
940
 
941
    FT_Byte*  buffer;
942
 
943
  } FTC_SBitRec;
944
 
945

946
947

A very compact structure used to describe a small glyph bitmap.

948

949
fields
950

951
952
width
953

The bitmap width in pixels.

954
955
height
956

The bitmap height in pixels.

957
958
left
959

The horizontal distance from the pen position to the left bitmap border (a.k.a. ‘left side bearing’, or ‘lsb’).

960
961
top
962

The vertical distance from the pen position (on the baseline) to the upper bitmap border (a.k.a. ‘top side bearing’). The distance is positive for upwards y coordinates.

963
964
format
965

The format of the glyph bitmap (monochrome or gray).

966
967
max_grays
968

Maximum gray level value (in the range 1 to 255).

969
970
pitch
971

The number of bytes per bitmap line. May be positive or negative.

972
973
xadvance
974

The horizontal advance width in pixels.

975
976
yadvance
977

The vertical advance height in pixels.

978
979
buffer
980

A pointer to the bitmap pixels.

981
982
983
984
985

986
[Index]
987
988
[TOC]
989
 
990
991

FTC_SBitCache

992
993
Defined in FT_CACHE_H (freetype/ftcache.h).
994

995
996
 
997
  typedef struct FTC_SBitCacheRec_*  FTC_SBitCache;
998
 
999

1000
1001

A handle to a small bitmap cache. These are special cache objects used to store small glyph bitmaps (and anti-aliased pixmaps) in a much more efficient way than the traditional glyph image cache implemented by FTC_ImageCache.

1002

1003
1004

1005
[Index]
1006
1007
[TOC]
1008
 
1009
1010

FTC_SBitCache_New

1011
1012
Defined in FT_CACHE_H (freetype/ftcache.h).
1013

1014
1015
 
1016
  FT_EXPORT( FT_Error )
1017
  FTC_SBitCache_New( FTC_Manager     manager,
1018
                     FTC_SBitCache  *acache );
1019
 
1020

1021
1022

Create a new cache to store small glyph bitmaps.

1023

1024
input
1025

1026
1027
manager
1028

A handle to the source cache manager.

1029
1030
1031
1032
output
1033

1034
1035
acache
1036

A handle to the new sbit cache. NULL in case of error.

1037
1038
1039
1040
return
1041

FreeType error code. 0 means success.

1042
1043
1044

1045
[Index]
1046
1047
[TOC]
1048
 
1049
1050

FTC_SBitCache_Lookup

1051
1052
Defined in FT_CACHE_H (freetype/ftcache.h).
1053

1054
1055
 
1056
  FT_EXPORT( FT_Error )
1057
  FTC_SBitCache_Lookup( FTC_SBitCache    cache,
1058
                        FTC_ImageType    type,
1059
                        FT_UInt          gindex,
1060
                        FTC_SBit        *sbit,
1061
                        FTC_Node        *anode );
1062
 
1063

1064
1065

Look up a given small glyph bitmap in a given sbit cache and ‘lock’ it to prevent its flushing from the cache until needed.

1066

1067
input
1068

1069
1070
cache
1071

A handle to the source sbit cache.

1072
1073
type
1074

A pointer to the glyph image type descriptor.

1075
1076
gindex
1077

The glyph index.

1078
1079
1080
1081
output
1082

1083
1084
sbit
1085

A handle to a small bitmap descriptor.

1086
1087
anode
1088

Used to return the address of of the corresponding cache node after incrementing its reference count (see note below).

1089
1090
1091
1092
return
1093

FreeType error code. 0 means success.

1094
1095
note
1096

The small bitmap descriptor and its bit buffer are owned by the cache and should never be freed by the application. They might as well disappear from memory on the next cache lookup, so don't treat them as persistent data.

1097

The descriptor's ‘buffer’ field is set to 0 to indicate a missing glyph bitmap.

1098

If ‘anode’ is not NULL, it receives the address of the cache node containing the bitmap, after increasing its reference count. This ensures that the node (as well as the image) will always be kept in the cache until you call FTC_Node_Unref to ‘release’ it.

1099

If ‘anode’ is NULL, the cache node is left unchanged, which means that the bitmap could be flushed out of the cache on the next call to one of the caching sub-system APIs. Don't assume that it is persistent!

1100
1101
1102

1103
[Index]
1104
1105
[TOC]
1106
 
1107
1108

FTC_SBitCache_LookupScaler

1109
1110
Defined in FT_CACHE_H (freetype/ftcache.h).
1111

1112
1113
 
1114
  FT_EXPORT( FT_Error )
1115
  FTC_SBitCache_LookupScaler( FTC_SBitCache  cache,
1116
                              FTC_Scaler     scaler,
1117
                              FT_ULong       load_flags,
1118
                              FT_UInt        gindex,
1119
                              FTC_SBit      *sbit,
1120
                              FTC_Node      *anode );
1121
 
1122

1123
1124

A variant of FTC_SBitCache_Lookup that uses an FTC_ScalerRec to specify the face ID and its size.

1125

1126
input
1127

1128
1129
cache
1130

A handle to the source sbit cache.

1131
1132
scaler
1133

A pointer to the scaler descriptor.

1134
1135
load_flags
1136

The corresponding load flags.

1137
1138
gindex
1139

The glyph index.

1140
1141
1142
1143
output
1144

1145
1146
sbit
1147

A handle to a small bitmap descriptor.

1148
1149
anode
1150

Used to return the address of of the corresponding cache node after incrementing its reference count (see note below).

1151
1152
1153
1154
return
1155

FreeType error code. 0 means success.

1156
1157
note
1158

The small bitmap descriptor and its bit buffer are owned by the cache and should never be freed by the application. They might as well disappear from memory on the next cache lookup, so don't treat them as persistent data.

1159

The descriptor's ‘buffer’ field is set to 0 to indicate a missing glyph bitmap.

1160

If ‘anode’ is not NULL, it receives the address of the cache node containing the bitmap, after increasing its reference count. This ensures that the node (as well as the image) will always be kept in the cache until you call FTC_Node_Unref to ‘release’ it.

1161

If ‘anode’ is NULL, the cache node is left unchanged, which means that the bitmap could be flushed out of the cache on the next call to one of the caching sub-system APIs. Don't assume that it is persistent!

1162
1163
1164

1165
[Index]
1166
1167
[TOC]
1168
 
1169
1170