Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/fileformats/ocd_file_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,23 +423,23 @@ Ocd::OcdPoint32 convertPoint(const MapCoord& coord)


/**
* Convert a size to the OCD format.
* Convert a size or offset to the OCD format.
*
* This function converts from 1/100 mm to 1/10 mm, rounding half up for positive values.
* This function converts from 1/100 mm to 1/10 mm, rounding halfway cases away from zero.
*/
constexpr qint16 convertSize(qint32 size)
{
return qint16((size+5) / 10);
return qint16(((size < 0) ? (size-5) : (size+5)) / 10);
}

/**
* Convert a size to the OCD format.
*
* This function converts from 1/100 mm to 1/10 mm, rounding half up for positive values.
* This function converts from 1/100 mm to 1/10 mm, rounding halfway cases away from zero.
*/
constexpr qint32 convertSize(qint64 size)
{
return qint32((size+5) / 10);
return qint32(((size < 0) ? (size-5) : (size+5)) / 10);
}


Expand Down Expand Up @@ -1877,6 +1877,7 @@ QByteArray OcdFileExport::exportTextSymbol(const TextSymbol* text_symbol, quint3
setupTextSymbolExtra(text_symbol, ocd_symbol);
setupTextSymbolBasic(text_symbol, alignment, ocd_symbol.basic);
setupTextSymbolSpecial(text_symbol, ocd_symbol.special);
setupTextSymbolFraming(text_symbol, ocd_symbol.framing);

auto header_size = int(sizeof(OcdTextSymbol));
ocd_symbol.base.size = decltype(ocd_symbol.base.size)(header_size);
Expand Down Expand Up @@ -1963,6 +1964,7 @@ void OcdFileExport::setupTextSymbolFraming(const TextSymbol* text_symbol, OcdTex
if (text_symbol->getFramingColor())
{
ocd_text_framing.color = convertColor(text_symbol->getFramingColor());
ocd_text_framing.line_style_V9 = (ocd_version >= 9) ? /* miter join */ 4 : 0;
switch (text_symbol->getFramingMode())
{
case TextSymbol::NoFraming:
Expand Down
6 changes: 6 additions & 0 deletions src/fileformats/ocd_file_import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,7 +2355,13 @@ void OcdFileImport::setFraming(OcdFileImport::OcdImportedTextSymbol* symbol, con
case Ocd::FramingLine: // since V7
symbol->framing = true;
symbol->framing_mode = TextSymbol::LineFraming;
symbol->framing_color = convertColor(framing.color);
symbol->framing_line_half_width = convertLength(framing.line_width);
if (ocd_version >= 9)
{
if (framing.line_style_V9 != 0 && framing.line_style_V9 != 4)
addSymbolWarning(symbol, tr("Ignoring text framing line style."));
}
break;
case Ocd::FramingRectangle:
default:
Expand Down
4 changes: 2 additions & 2 deletions src/fileformats/ocd_types_v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ namespace Ocd
quint16 line_width;
quint16 font_weight; /// TextSymbol only
quint16 italic; /// TextSymbol only
quint16 offset_x;
quint16 offset_y;
qint16 offset_x;
qint16 offset_y;
};

struct TextSymbolV8
Expand Down