1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* psmodule.c */ |
3 * psmodule.c |
4 /* */ |
4 * |
5 /* PSNames module implementation (body). */ |
5 * psnames module implementation (body). |
6 /* */ |
6 * |
7 /* Copyright 1996-2018 by */ |
7 * Copyright (C) 1996-2019 by |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
8 * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 /* */ |
9 * |
10 /* This file is part of the FreeType project, and may only be used, */ |
10 * This file is part of the FreeType project, and may only be used, |
11 /* modified, and distributed under the terms of the FreeType project */ |
11 * modified, and distributed under the terms of the FreeType project |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
13 /* this file you indicate that you have read the license and */ |
13 * this file you indicate that you have read the license and |
14 /* understand and accept it fully. */ |
14 * understand and accept it fully. |
15 /* */ |
15 * |
16 /***************************************************************************/ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <ft2build.h> |
19 #include <ft2build.h> |
20 #include FT_INTERNAL_DEBUG_H |
20 #include FT_INTERNAL_DEBUG_H |
21 #include FT_INTERNAL_OBJECTS_H |
21 #include FT_INTERNAL_OBJECTS_H |
22 #include FT_SERVICE_POSTSCRIPT_CMAPS_H |
22 #include FT_SERVICE_POSTSCRIPT_CMAPS_H |
23 |
23 |
24 #include "psmodule.h" |
24 #include "psmodule.h" |
25 |
25 |
26 /* |
26 /* |
27 * The file `pstables.h' with its arrays and its function |
27 * The file `pstables.h' with its arrays and its function |
28 * `ft_get_adobe_glyph_index' is useful for other projects also (for |
28 * `ft_get_adobe_glyph_index' is useful for other projects also (for |
29 * example, `pdfium' is using it). However, if used as a C++ header, |
29 * example, `pdfium' is using it). However, if used as a C++ header, |
30 * including it in two different source files makes it necessary to use |
30 * including it in two different source files makes it necessary to use |
31 * `extern const' for the declaration of its arrays, otherwise the data |
31 * `extern const' for the declaration of its arrays, otherwise the data |
32 * would be duplicated as mandated by the C++ standard. |
32 * would be duplicated as mandated by the C++ standard. |
33 * |
33 * |
34 * For this reason, we use `DEFINE_PS_TABLES' to guard the function |
34 * For this reason, we use `DEFINE_PS_TABLES' to guard the function |
35 * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array |
35 * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array |
36 * declarations and definitions. |
36 * declarations and definitions. |
37 */ |
37 */ |
38 #include "pstables.h" |
38 #include "pstables.h" |
39 #define DEFINE_PS_TABLES |
39 #define DEFINE_PS_TABLES |
40 #define DEFINE_PS_TABLES_DATA |
40 #define DEFINE_PS_TABLES_DATA |
41 #include "pstables.h" |
41 #include "pstables.h" |
42 |
42 |
43 #include "psnamerr.h" |
43 #include "psnamerr.h" |
44 #include "pspic.h" |
|
45 |
44 |
46 |
45 |
47 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES |
46 #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES |
48 |
47 |
49 |
48 |
391 else |
390 else |
392 { |
391 { |
393 /* Reallocate if the number of used entries is much smaller. */ |
392 /* Reallocate if the number of used entries is much smaller. */ |
394 if ( count < num_glyphs / 2 ) |
393 if ( count < num_glyphs / 2 ) |
395 { |
394 { |
396 (void)FT_RENEW_ARRAY( table->maps, num_glyphs, count ); |
395 (void)FT_RENEW_ARRAY( table->maps, |
|
396 num_glyphs + EXTRA_GLYPH_LIST_SIZE, |
|
397 count ); |
397 error = FT_Err_Ok; |
398 error = FT_Err_Ok; |
398 } |
399 } |
399 |
400 |
400 /* Sort the table in increasing order of unicode values, */ |
401 /* Sort the table in increasing order of unicode values, */ |
401 /* taking care of glyph variants. */ |
402 /* taking care of glyph variants. */ |
575 |
576 |
576 |
577 |
577 FT_DEFINE_SERVICEDESCREC1( |
578 FT_DEFINE_SERVICEDESCREC1( |
578 pscmaps_services, |
579 pscmaps_services, |
579 |
580 |
580 FT_SERVICE_ID_POSTSCRIPT_CMAPS, &PSCMAPS_INTERFACE_GET ) |
581 FT_SERVICE_ID_POSTSCRIPT_CMAPS, &pscmaps_interface ) |
581 |
582 |
582 |
583 |
583 static FT_Pointer |
584 static FT_Pointer |
584 psnames_get_service( FT_Module module, |
585 psnames_get_service( FT_Module module, |
585 const char* service_id ) |
586 const char* service_id ) |
586 { |
587 { |
587 /* PSCMAPS_SERVICES_GET dereferences `library' in PIC mode */ |
|
588 #ifdef FT_CONFIG_OPTION_PIC |
|
589 FT_Library library; |
|
590 |
|
591 |
|
592 if ( !module ) |
|
593 return NULL; |
|
594 library = module->library; |
|
595 if ( !library ) |
|
596 return NULL; |
|
597 #else |
|
598 FT_UNUSED( module ); |
588 FT_UNUSED( module ); |
599 #endif |
589 |
600 |
590 return ft_service_list_lookup( pscmaps_services, service_id ); |
601 return ft_service_list_lookup( PSCMAPS_SERVICES_GET, service_id ); |
|
602 } |
591 } |
603 |
592 |
604 #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ |
593 #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ |
605 |
594 |
606 |
595 |
619 "psnames", /* driver name */ |
608 "psnames", /* driver name */ |
620 0x10000L, /* driver version */ |
609 0x10000L, /* driver version */ |
621 0x20000L, /* driver requires FreeType 2 or above */ |
610 0x20000L, /* driver requires FreeType 2 or above */ |
622 |
611 |
623 PUT_PS_NAMES_SERVICE( |
612 PUT_PS_NAMES_SERVICE( |
624 (void*)&PSCMAPS_INTERFACE_GET ), /* module specific interface */ |
613 (void*)&pscmaps_interface ), /* module specific interface */ |
625 |
614 |
626 (FT_Module_Constructor)NULL, /* module_init */ |
615 (FT_Module_Constructor)NULL, /* module_init */ |
627 (FT_Module_Destructor) NULL, /* module_done */ |
616 (FT_Module_Destructor) NULL, /* module_done */ |
628 (FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) /* get_interface */ |
617 (FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) /* get_interface */ |
629 ) |
618 ) |