forked from microsoft/terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlyphWidth.cpp
More file actions
50 lines (44 loc) · 1.58 KB
/
Copy pathGlyphWidth.cpp
File metadata and controls
50 lines (44 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include "inc/CodepointWidthDetector.hpp"
#include "inc/GlyphWidth.hpp"
static CodepointWidthDetector widthDetector;
// Function Description:
// - determines if the glyph represented by the string of characters should be
// wide or not. See CodepointWidthDetector::IsWide
bool IsGlyphFullWidth(const std::wstring_view glyph)
{
return widthDetector.IsWide(glyph);
}
// Function Description:
// - determines if the glyph represented by the single character should be
// wide or not. See CodepointWidthDetector::IsWide
bool IsGlyphFullWidth(const wchar_t wch)
{
return widthDetector.IsWide(wch);
}
// Function Description:
// - Sets a function that should be used by the global CodepointWidthDetector
// as the fallback mechanism for determining a particular glyph's width,
// should the glyph be an ambiguous width.
// A Terminal could hook in a Renderer's IsGlyphWideByFont method as the
// fallback to ask the renderer for the glyph's width (for example).
// Arguments:
// - pfnFallback - the function to use as the fallback method.
// Return Value:
// - <none>
void SetGlyphWidthFallback(std::function<bool(const std::wstring_view)> pfnFallback)
{
widthDetector.SetFallbackMethod(pfnFallback);
}
// Function Description:
// - Forwards notification about font changing to glyph width detector
// Arguments:
// - <none>
// Return Value:
// - <none>
void NotifyGlyphWidthFontChanged()
{
widthDetector.NotifyFontChanged();
}