vsg: include/vsg/text/Font.h Source File

vsg 1.1.10 VulkanSceneGraph library |

Loading...
Searching...
No Matches
Font.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2020 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/core/Data.h>
16#include <vsg/io/Options.h>
17#include <vsg/state/ImageInfo.h>
18#include <vsg/text/GlyphMetrics.h>
19#include <vsg/utils/SharedObjects.h>
20
21namespace vsg
22{
23 class VSG_DECLSPEC Font : public Inherit<Object, Font>
24 {
25 public:
26 Font();
27
28 void read(Input& input) override;
29 void write(Output& output) const override;
30
31 float ascender = 1.0f; // maximum ascent below the baseline
32 float descender = 0.0f; // maximum descent below the baseline
33 float height = 1.0f; // vertical distance between two consecutive baselines
34
35 ref_ptr<Data> atlas;
36 ref_ptr<GlyphMetricsArray> glyphMetrics;
37 ref_ptr<uintArray> charmap;
38 ref_ptr<SharedObjects> sharedObjects;
39 ref_ptr<ImageInfo> atlasImageInfo;
40 ref_ptr<ImageInfo> glyphImageInfo;
41
43 uint32_t glyphIndexForCharcode(uint32_t charcode) const
44 {
45 if (charmap && charcode < charmap->size()) return charmap->at(charcode);
46 return 0;
47 }
48 void createFontImages();
49
50 protected:
51 };
52 VSG_type_name(vsg::Font);
53
54} // namespace vsg
vsg::Font
Definition Font.h:24
vsg::Font::glyphIndexForCharcode
uint32_t glyphIndexForCharcode(uint32_t charcode) const
get the index into the glyphMetrics array for the glyph associated with specified charcode
Definition Font.h:43
vsg::Input
Definition Input.h:44
vsg::Output
Definition Output.h:41
vsg::ref_ptr
Definition ref_ptr.h:22