1f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod/* 22409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 2009 Red Hat, Inc. 3f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * 4c755cb3e3ac55156d0d2ec05adea7a650b97cc41Behdad Esfahbod * This is part of HarfBuzz, a text shaping library. 5f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * 6f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * Permission is hereby granted, without written agreement and without 7f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 8f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * software and its documentation for any purpose, provided that the 9f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * above copyright notice and the following two paragraphs appear in 10f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * all copies of this software. 11f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * 12f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 13f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 14f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 15f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 16f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * DAMAGE. 17f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * 18f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 19f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 21f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 22f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 23f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * 24f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod * Red Hat Author(s): Behdad Esfahbod 25f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod */ 26f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 27d1c9eb458c843215da8df84b596bfae51fee135bBehdad Esfahbod#ifndef HB_H_IN 28d1c9eb458c843215da8df84b596bfae51fee135bBehdad Esfahbod#error "Include <hb.h> instead." 29d1c9eb458c843215da8df84b596bfae51fee135bBehdad Esfahbod#endif 30d1c9eb458c843215da8df84b596bfae51fee135bBehdad Esfahbod 31f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod#ifndef HB_BLOB_H 32f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod#define HB_BLOB_H 33f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 34f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod#include "hb-common.h" 35f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 36f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad EsfahbodHB_BEGIN_DECLS 37f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 38acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 39c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod/* 40c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * Note re various memory-modes: 41c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * 42c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * - In no case shall the HarfBuzz client modify memory 43c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * that is passed to HarfBuzz in a blob. If there is 44c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * any such possibility, MODE_DUPLICATE should be used 45c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * such that HarfBuzz makes a copy immediately, 46c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * 47c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * - Use MODE_READONLY otherse, unless you really really 48c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * really know what you are doing, 49c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * 50c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * - MODE_WRITABLE is appropriate if you relaly made a 51c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * copy of data solely for the purpose of passing to 52c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * HarfBuzz and doing that just once (no reuse!), 53c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * 54c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * - If the font is mmap()ed, it's ok to use 55c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * READONLY_MAY_MAKE_WRITABLE, however, there were 56c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * design problems with that mode, so HarfBuzz do not 57c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * really use it anymore. If not sure, use MODE_READONLY. 58c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod */ 595e88aa66822ba64324b4428c9ffbe06a43b4f310Behdad Esfahbodtypedef enum { 60f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod HB_MEMORY_MODE_DUPLICATE, 61f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod HB_MEMORY_MODE_READONLY, 62977eeb714454630bd045bb11f58ff6397f10b143Behdad Esfahbod HB_MEMORY_MODE_WRITABLE, 63977eeb714454630bd045bb11f58ff6397f10b143Behdad Esfahbod HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE 64f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod} hb_memory_mode_t; 65f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 661bc1cb3603167f5da309336f7018c8b0608ac104Behdad Esfahbodtypedef struct hb_blob_t hb_blob_t; 670cc7bc59ea6e8f38bf1e196c558cca9862ac3302Behdad Esfahbod 68f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbodhb_blob_t * 69f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbodhb_blob_create (const char *data, 70a26442437ae9f11674e0d68cd5cbf395ade7695dBehdad Esfahbod unsigned int length, 71f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod hb_memory_mode_t mode, 72e5847f75fb7bd25c5db6061d8e20d61fa469f9feBehdad Esfahbod void *user_data, 73e5847f75fb7bd25c5db6061d8e20d61fa469f9feBehdad Esfahbod hb_destroy_func_t destroy); 74f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 75c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod/* Always creates with MEMORY_MODE_READONLY. 76c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * Even if the parent blob is writable, we don't 77c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * want the user of the sub-blob to be able to 78c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * modify the parent data as that data may be 79c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod * shared among multiple sub-blobs. 80c3ba49b6fa1865e8318926eaa6c0f2063d1053bbBehdad Esfahbod */ 81f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbodhb_blob_t * 82a26442437ae9f11674e0d68cd5cbf395ade7695dBehdad Esfahbodhb_blob_create_sub_blob (hb_blob_t *parent, 83a26442437ae9f11674e0d68cd5cbf395ade7695dBehdad Esfahbod unsigned int offset, 84a26442437ae9f11674e0d68cd5cbf395ade7695dBehdad Esfahbod unsigned int length); 85a26442437ae9f11674e0d68cd5cbf395ade7695dBehdad Esfahbod 86a26442437ae9f11674e0d68cd5cbf395ade7695dBehdad Esfahbodhb_blob_t * 874911062d5be0d937ee8f1a70cc93e05d162f45b3Behdad Esfahbodhb_blob_get_empty (void); 88a26442437ae9f11674e0d68cd5cbf395ade7695dBehdad Esfahbod 89a26442437ae9f11674e0d68cd5cbf395ade7695dBehdad Esfahbodhb_blob_t * 90f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbodhb_blob_reference (hb_blob_t *blob); 91f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 92f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbodvoid 93f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbodhb_blob_destroy (hb_blob_t *blob); 94f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 955fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_bool_t 965fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_blob_set_user_data (hb_blob_t *blob, 975fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key, 985fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod void * data, 9933ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_destroy_func_t destroy, 10033ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_bool_t replace); 1015fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 1025fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 1035fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodvoid * 1045fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_blob_get_user_data (hb_blob_t *blob, 1055fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key); 1065fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 1075fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 1081c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbodvoid 1091c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbodhb_blob_make_immutable (hb_blob_t *blob); 1101c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbod 1111c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbodhb_bool_t 1121c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbodhb_blob_is_immutable (hb_blob_t *blob); 1131c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbod 1141c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbod 115fc6c94002dd5478cf9fbdaff12d8374a786c85e1Behdad Esfahbodunsigned int 116fc6c94002dd5478cf9fbdaff12d8374a786c85e1Behdad Esfahbodhb_blob_get_length (hb_blob_t *blob); 117fc6c94002dd5478cf9fbdaff12d8374a786c85e1Behdad Esfahbod 118f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbodconst char * 1191c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbodhb_blob_get_data (hb_blob_t *blob, unsigned int *length); 120fc6c94002dd5478cf9fbdaff12d8374a786c85e1Behdad Esfahbod 1211c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbodchar * 1221c9f8717eb12c37c219333cbb0d123e1d2da4896Behdad Esfahbodhb_blob_get_data_writable (hb_blob_t *blob, unsigned int *length); 123f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 124acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 125f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad EsfahbodHB_END_DECLS 126f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod 127f0954d1e08ae288eda9904e17108fc73f48c0b98Behdad Esfahbod#endif /* HB_BLOB_H */ 128