2021-12-31 14:07:24 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
|
|
|
|
* Copyright (C) 2013 CERN
|
2022-01-04 00:44:59 +00:00
|
|
|
* Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-12-31 14:07:24 +00:00
|
|
|
*
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* Stroke font class
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef STROKE_FONT_H
|
|
|
|
#define STROKE_FONT_H
|
|
|
|
|
2023-09-26 11:40:17 +00:00
|
|
|
#include <gal/gal.h>
|
2021-12-31 14:07:24 +00:00
|
|
|
#include <map>
|
|
|
|
#include <deque>
|
|
|
|
#include <algorithm>
|
2023-09-08 02:09:26 +00:00
|
|
|
#include <core/utf8.h>
|
2021-12-31 14:07:24 +00:00
|
|
|
#include <math/box2.h>
|
|
|
|
#include <font/font.h>
|
|
|
|
|
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class GAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KIFONT
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Implement a stroke font drawing.
|
|
|
|
*
|
|
|
|
* A stroke font is composed of lines.
|
|
|
|
*/
|
2023-09-26 11:40:17 +00:00
|
|
|
class GAL_API STROKE_FONT : public FONT
|
2021-12-31 14:07:24 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
STROKE_FONT();
|
|
|
|
|
|
|
|
bool IsStroke() const override { return true; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a stroke font.
|
|
|
|
*
|
|
|
|
* @param aFontName is the name of the font. If empty, the standard KiCad stroke font is
|
|
|
|
* loaded.
|
|
|
|
*/
|
|
|
|
static STROKE_FONT* LoadFont( const wxString& aFontName );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute the distance (interline) between 2 lines of text (for multiline texts). This is
|
|
|
|
* the distance between baselines, not the space between line bounding boxes.
|
|
|
|
*/
|
2023-08-06 19:20:53 +00:00
|
|
|
double GetInterline( double aGlyphHeight, const METRICS& aFontMetrics ) const override;
|
2021-12-31 14:07:24 +00:00
|
|
|
|
2022-01-07 17:42:43 +00:00
|
|
|
VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
|
2022-01-25 22:33:37 +00:00
|
|
|
const wxString& aText, const VECTOR2I& aSize,
|
|
|
|
const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, bool aMirror,
|
|
|
|
const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const override;
|
2021-12-31 14:07:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Load the standard KiCad stroke font.
|
|
|
|
*
|
|
|
|
* @param aNewStrokeFont is the pointer to the font data.
|
|
|
|
* @param aNewStrokeFontSize is the size of the font data.
|
|
|
|
*/
|
|
|
|
void loadNewStrokeFont( const char* const aNewStrokeFont[], int aNewStrokeFontSize );
|
|
|
|
|
|
|
|
private:
|
2022-01-04 00:44:59 +00:00
|
|
|
const std::vector<std::shared_ptr<GLYPH>>* m_glyphs;
|
2024-02-05 15:30:44 +00:00
|
|
|
const std::vector<BOX2D>* m_glyphBoundingBoxes;
|
2022-01-04 00:44:59 +00:00
|
|
|
double m_maxGlyphWidth;
|
2021-12-31 14:07:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace KIFONT
|
|
|
|
|
|
|
|
#endif // STROKE_FONT_H
|