2013-02-27 19:01:02 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2010,2011,2013 Google, Inc.
|
|
|
|
*
|
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*
|
|
|
|
* Google Author(s): Behdad Esfahbod
|
|
|
|
*/
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb.hh"
|
2013-02-27 19:01:02 +01:00
|
|
|
|
|
|
|
#include "hb.h"
|
2017-10-29 02:54:04 +01:00
|
|
|
#include "hb-ot.h"
|
2013-02-27 23:59:28 +01:00
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
#include "hb-ft.h"
|
|
|
|
#endif
|
2013-02-27 19:01:02 +01:00
|
|
|
|
2019-06-24 23:12:42 +02:00
|
|
|
#ifdef HB_NO_OPEN
|
2021-06-14 23:46:04 +02:00
|
|
|
#define hb_blob_create_from_file_or_fail(x) hb_blob_get_empty ()
|
2019-06-24 23:12:42 +02:00
|
|
|
#endif
|
|
|
|
|
2013-02-27 19:01:02 +01:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2019-06-18 22:26:03 +02:00
|
|
|
bool ret = true;
|
|
|
|
|
|
|
|
#ifndef HB_NO_BUFFER_SERIALIZE
|
|
|
|
|
2022-11-15 00:24:25 +01:00
|
|
|
if (argc < 2)
|
|
|
|
argv[1] = (char *) "/dev/null";
|
2013-02-27 19:01:02 +01:00
|
|
|
|
2021-06-14 23:46:04 +02:00
|
|
|
hb_blob_t *blob = hb_blob_create_from_file_or_fail (argv[1]);
|
|
|
|
assert (blob);
|
2013-02-27 19:01:02 +01:00
|
|
|
hb_face_t *face = hb_face_create (blob, 0 /* first face */);
|
|
|
|
hb_blob_destroy (blob);
|
2017-10-15 12:11:08 +02:00
|
|
|
blob = nullptr;
|
2013-02-27 19:01:02 +01:00
|
|
|
|
|
|
|
unsigned int upem = hb_face_get_upem (face);
|
|
|
|
hb_font_t *font = hb_font_create (face);
|
2013-02-27 23:59:28 +01:00
|
|
|
hb_face_destroy (face);
|
2013-02-27 19:01:02 +01:00
|
|
|
hb_font_set_scale (font, upem, upem);
|
2022-11-15 00:24:25 +01:00
|
|
|
//hb_ot_font_set_funcs (font);
|
2013-02-27 23:59:28 +01:00
|
|
|
#ifdef HAVE_FREETYPE
|
2017-10-29 02:54:04 +01:00
|
|
|
//hb_ft_font_set_funcs (font);
|
2013-02-27 23:59:28 +01:00
|
|
|
#endif
|
2013-02-27 19:01:02 +01:00
|
|
|
|
|
|
|
hb_buffer_t *buf;
|
|
|
|
buf = hb_buffer_create ();
|
|
|
|
|
|
|
|
char line[BUFSIZ], out[BUFSIZ];
|
2020-04-20 21:18:23 +02:00
|
|
|
while (fgets (line, sizeof(line), stdin))
|
2013-02-27 19:01:02 +01:00
|
|
|
{
|
|
|
|
hb_buffer_clear_contents (buf);
|
|
|
|
|
2013-02-27 23:59:28 +01:00
|
|
|
const char *p = line;
|
|
|
|
while (hb_buffer_deserialize_glyphs (buf,
|
|
|
|
p, -1, &p,
|
|
|
|
font,
|
2022-07-02 00:52:49 +02:00
|
|
|
HB_BUFFER_SERIALIZE_FORMAT_TEXT))
|
2013-02-27 23:59:28 +01:00
|
|
|
;
|
|
|
|
if (*p && *p != '\n')
|
2013-02-27 19:01:02 +01:00
|
|
|
ret = false;
|
|
|
|
|
|
|
|
hb_buffer_serialize_glyphs (buf, 0, hb_buffer_get_length (buf),
|
2017-10-15 12:11:08 +02:00
|
|
|
out, sizeof (out), nullptr,
|
2022-07-02 00:52:49 +02:00
|
|
|
font, HB_BUFFER_SERIALIZE_FORMAT_TEXT,
|
|
|
|
HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS);
|
2013-02-27 19:01:02 +01:00
|
|
|
puts (out);
|
|
|
|
}
|
|
|
|
|
|
|
|
hb_buffer_destroy (buf);
|
|
|
|
|
|
|
|
hb_font_destroy (font);
|
|
|
|
|
2019-06-18 22:26:03 +02:00
|
|
|
#endif
|
|
|
|
|
2013-02-27 19:01:02 +01:00
|
|
|
return !ret;
|
|
|
|
}
|