-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed FontAttributes to FontProperties and moved it to a higher level
- Loading branch information
Kees van Spelde
committed
Dec 16, 2022
1 parent
bec532e
commit 72b77a8
Showing
10 changed files
with
317 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// FontAttributes.cs | ||
// | ||
// Author: Kees van Spelde <[email protected]> | ||
// | ||
// Copyright 2012-2019 Charles Weld | ||
// Copyright 2021-2022 Kees van Spelde | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// | ||
// - You may not use this file except in compliance with the License. | ||
// - You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace TesseractOCR.Font | ||
{ | ||
/// <summary> | ||
/// This struct is the return type of ResultIterator.GetWordFontAttributes(). | ||
/// We can't use FontInfo directly because there are properties here that are not | ||
/// accounted for in FontInfo (smallcaps, underline, etc.) Because of the caching | ||
/// scheme we're using for FontInfo objects, we can't simply augment that class since | ||
/// these extra properties are not accounted for by the FontInfo's unique ID. | ||
/// </summary> | ||
public sealed class Attributes | ||
{ | ||
#region Properties | ||
/// <summary> | ||
/// Returns the font information | ||
/// </summary> | ||
public Info FontInfo { get; } | ||
|
||
/// <summary> | ||
/// Returns <c>true</c> when the text is underlined | ||
/// </summary> | ||
public bool IsUnderlined { get; } | ||
|
||
/// <summary> | ||
/// Returns <c>true</c> when the font is small caps | ||
/// </summary> | ||
public bool IsSmallCaps { get; } | ||
#endregion | ||
|
||
#region Constructor | ||
/// <summary> | ||
/// Creates this object and sets all it's needed properties | ||
/// </summary> | ||
/// <param name="fontInfo"></param> | ||
/// <param name="isUnderlined"></param> | ||
/// <param name="isSmallCaps"></param> | ||
internal Attributes(Info fontInfo, bool isUnderlined, bool isSmallCaps) | ||
{ | ||
FontInfo = fontInfo; | ||
IsUnderlined = isUnderlined; | ||
IsSmallCaps = isSmallCaps; | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// Info.cs | ||
// | ||
// Author: Kees van Spelde <[email protected]> | ||
// | ||
// Copyright 2012-2019 Charles Weld | ||
// Copyright 2021-2022 Kees van Spelde | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// | ||
// - You may not use this file except in compliance with the License. | ||
// - You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace TesseractOCR.Font | ||
{ | ||
/// <summary> | ||
/// The .NET equivalent of the ccstruct/fontinfo.h | ||
/// FontInfo struct. It's missing spacing info | ||
/// since we don't have any way of getting it (and | ||
/// it's probably not all that useful anyway) | ||
/// </summary> | ||
public readonly struct Info | ||
{ | ||
#region Properties | ||
/// <summary> | ||
/// Returns the name of the font | ||
/// </summary> | ||
public string Name { get; } | ||
|
||
/// <summary> | ||
/// Returns the id of the font | ||
/// </summary> | ||
public int Id { get; } | ||
|
||
/// <summary> | ||
/// Returns <c>true</c> when the font is in italic | ||
/// </summary> | ||
public bool IsItalic { get; } | ||
|
||
/// <summary> | ||
/// Returns <c>true</c> when the font is bold | ||
/// </summary> | ||
public bool IsBold { get; } | ||
|
||
/// <summary> | ||
/// Returns <c>true</c> when the font has a fixed pitch | ||
/// </summary> | ||
public bool IsFixedPitch { get; } | ||
|
||
/// <summary> | ||
/// Returns <c>true</c> when the font is serif | ||
/// </summary> | ||
public bool IsSerif { get; } | ||
|
||
/// <summary> | ||
/// Returns <c>true</c> when the font is fraktur | ||
/// </summary> | ||
public bool IsFraktur { get; } | ||
#endregion | ||
|
||
#region Constructor | ||
internal Info(string name, int id, bool isItalic, bool isBold, bool isFixedPitch, bool isSerif, | ||
bool isFraktur = false) | ||
{ | ||
Name = name; | ||
Id = id; | ||
IsItalic = isItalic; | ||
IsBold = isBold; | ||
IsFixedPitch = isFixedPitch; | ||
IsSerif = isSerif; | ||
IsFraktur = isFraktur; | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// Properties.cs | ||
// | ||
// Author: Kees van Spelde <[email protected]> | ||
// | ||
// Copyright 2021-2022 Kees van Spelde | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// | ||
// - You may not use this file except in compliance with the License. | ||
// - You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using TesseractOCR.Enums; | ||
|
||
namespace TesseractOCR.Font | ||
{ | ||
/// <summary> | ||
/// Returns font properties | ||
/// </summary> | ||
public class Properties | ||
{ | ||
/// <summary> | ||
/// Returns the point size of the font | ||
/// </summary> | ||
/// <remarks> | ||
/// Point size is returned in printers points (1/72 inch) | ||
/// </remarks> | ||
public int PointSize { get; } | ||
|
||
/// <summary> | ||
/// Returns other font attributes | ||
/// </summary> | ||
/// <remarks> | ||
/// This information is only available when using older engine modes like | ||
/// <see cref="EngineMode.TesseractOnly "/> and <see cref="EngineMode.TesseractAndLstm "/> | ||
/// </remarks> | ||
public Attributes Attributes { get; } | ||
|
||
internal Properties(int pointSize, Attributes attributes = null) | ||
{ | ||
PointSize = pointSize; | ||
Attributes = attributes; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.