1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_FONT_TEST_H
7 #define GFX_FONT_TEST_H
12 #include "cairo/cairo.h"
14 struct gfxFontTestItem
{
15 gfxFontTestItem(const nsCString
& fontName
,
16 cairo_glyph_t
*cglyphs
, int nglyphs
)
17 : platformFont(fontName
)
19 glyphs
= new cairo_glyph_t
[nglyphs
];
20 memcpy (glyphs
, cglyphs
, sizeof(cairo_glyph_t
) * nglyphs
);
24 gfxFontTestItem(const gfxFontTestItem
& other
) {
25 platformFont
= other
.platformFont
;
26 num_glyphs
= other
.num_glyphs
;
27 glyphs
= new cairo_glyph_t
[num_glyphs
];
28 memcpy (glyphs
, other
.glyphs
, sizeof(cairo_glyph_t
) * num_glyphs
);
35 nsCString platformFont
;
36 cairo_glyph_t
*glyphs
;
41 class gfxFontTestStore
{
43 gfxFontTestStore() { }
45 void AddItem (const nsCString
& fontString
,
46 cairo_glyph_t
*cglyphs
, int nglyphs
)
48 items
.AppendElement(gfxFontTestItem(fontString
, cglyphs
, nglyphs
));
51 void AddItem (const nsString
& fontString
,
52 cairo_glyph_t
*cglyphs
, int nglyphs
)
54 items
.AppendElement(gfxFontTestItem(NS_ConvertUTF16toUTF8(fontString
), cglyphs
, nglyphs
));
57 nsTArray
<gfxFontTestItem
> items
;
60 static gfxFontTestStore
*CurrentStore() {
64 static gfxFontTestStore
*NewStore() {
68 sCurrentStore
= new gfxFontTestStore
;
72 static void DeleteStore() {
76 sCurrentStore
= nullptr;
80 static gfxFontTestStore
*sCurrentStore
;
84 #endif /* GFX_FONT_TEST_H */